const express = require('express')

const router = express.Router()

const users = require('../../data/router/user.js')
const routers = require('../../data/router/routes.js')

router.get('/getRoutes', (req, res) => {
    res.setHeader('content-type', 'text/html;charset=utf-8')
    const uid = 1
    let authRotuterInfo = []
    const userInfo = users.filter(user => user.id === uid)[0]
    userInfo.hasAuth.map((rid) => {
        routers.map((router) => {
            if (router.id === rid) {
                authRotuterInfo.push(router)
            }
        })
    })
    res.end(JSON.stringify(authRotuterInfo))
})

//暴露 router
module.exports = router;